package com.gisuni.sddc.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.json.JSONArray;
import org.json.JSONObject;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import com.gisuni.sddc.dao.AdvQueryDao;
import com.gisuni.sddc.dao.LandStatisticsDao;
import com.gisuni.sddc.dao.RegionStaticDao;

@IocBean
public class RegionStaticService {

	private Log log = Logs.getLog(RegionStaticService.class);
	
	@Inject
	private RegionStaticDao regionStaticDao;
	
	/**
	 * 包含土地类型和控规的高级查询
	 * @param map
	 * @return
	 */
	public Map<String,Object> staticLandNumAndArea(JSONObject tableObj) {
		String tableName = tableObj.getString("tableName");
		String queryFild = tableObj.getString("queryFild");
		String city=tableObj.getString("csmc");
		String county=tableObj.getString("fqmc");
		String town=tableObj.getString("zjmc");
		Map<String,Object> map=new HashMap<String,Object>();
		map = regionStaticDao.staticLandNumAndArea(tableName,queryFild,city,county,town);
		return map;
	}
	public Map<String, Object> staticExtendBlockNumAndArea(JSONObject jsonObj) {
		String tableName = jsonObj.getString("tableName");
		String queryFild = jsonObj.getString("currentQueryExtendStyleName");
		String city=jsonObj.getString("csmc");
		String county=jsonObj.getString("fqmc");
		String town=jsonObj.getString("zjmc");
		Map<String,Object> map=new HashMap<String,Object>();
		if(!jsonObj.getBoolean("isManager")){
			JSONArray managerUsers=jsonObj.getJSONArray("managerUser");
			map = regionStaticDao.staticExtendBlockNumAndArea(tableName,queryFild,managerUsers);
		}else{
			map = regionStaticDao.staticExtendBlockNumAndArea(tableName,queryFild,city,county,town);
		}
		return map;
	}
	/**
	 * 人员完成度的统计
	 * @param companyNameList
	 * @return
	 */
	public Map<String, Object> personCompletePercentStatic(ArrayList<String> companyNameList,String startDate,String endDate) {
		Map<String,Object> map=new HashMap<String,Object>();
		for(String companyName : companyNameList){
			map.put(companyName, new HashMap<String,Object>());
		}
		map=regionStaticDao.personCompletePercentStatic(map,startDate,endDate);
		return map;
	}
}
